"""
@File    ：page_repair_config.py
@Author  ：ixiaodu
@Date    ：2024/8/9
@Desc    ：
"""
import allure
from common.page_base import Base
from page_element import el_repair_config
from utils.timer import sleep


class PageRepairConfig(Base):
    """维修配置页面"""

    def switch_to_tabs(self, tab_type):
        """切换tab页方法"""
        if tab_type == "上报类型":
            self.base_click(el_repair_config.report_type)
        elif tab_type == "维修项目":
            self.base_click(el_repair_config.repair_project)
        elif tab_type == "维修费用":
            self.base_click(el_repair_config.repair_fee)
        elif tab_type == "支付配置":
            self.base_click(el_repair_config.fee_config)
        elif tab_type == "评价配置":
            self.base_click(el_repair_config.evaluate_config)
        sleep()

    def click_report_type_add(self):
        """点击上报类型新增"""
        self.base_click(el_repair_config.report_type_add)
        sleep()

    def input_type_name(self, type_name):
        """输入类型名称方法"""
        self.base_input(el_repair_config.type_name, type_name)
        sleep()

    def select_icon_color(self):
        """选择图标颜色"""
        self.base_click(el_repair_config.icon_color)
        sleep()

    def select_icon_shape(self):
        """选择图标形状"""
        self.base_click(el_repair_config.icon_shape)
        sleep()

    def input_report_type_remark(self, remark):
        """输入备注方法"""
        self.base_input(el_repair_config.report_type_remark, remark)
        sleep()

    def click_report_type_submit(self):
        """点击新建确认按钮"""
        self.base_click(el_repair_config.report_type_submit)
        sleep()

    def click_association_personnel(self):
        """点击关联人员方法"""
        self.base_click(el_repair_config.association_personnel)
        sleep()

    def select_personnel_options(self):
        """选择人员方法"""
        self.base_click(el_repair_config.personnel_options)
        sleep()

    def click_association_personnel_submit(self):
        """点击关联人员确认按钮"""
        self.base_click(el_repair_config.association_personnel_submit)
        sleep()

    def add_report_type(self, type_name, remark):
        """新增上报类型"""
        with allure.step("点击新增按钮"):
            self.click_report_type_add()
        with allure.step(f"类型名称输入{type_name}"):
            self.input_type_name(type_name)
        with allure.step("选择图标颜色"):
            self.select_icon_color()
        with allure.step("选择图标形状"):
            self.select_icon_shape()
        with allure.step(f"备注输入{remark}"):
            self.input_report_type_remark(remark)
        with allure.step("点击确定按钮"):
            self.click_report_type_submit()

    def select_association_personnel(self):
        """关联人员方法"""
        with allure.step("点击关联人员"):
            self.click_association_personnel()
        with allure.step("选择关联人员"):
            self.select_personnel_options()
        with allure.step("点击提交"):
            self.click_association_personnel_submit()

    def click_repair_project_add(self):
        """点击维修项目新增"""
        self.base_click(el_repair_config.repair_project_add)
        sleep()

    def select_repair_project_report_type(self):
        """选择上报类型"""
        self.base_click(el_repair_config.repair_project_report_type)
        sleep()
        self.base_click(el_repair_config.repair_project_report_type1)
        sleep()

    def input_repair_project_name(self, name):
        """输入项目名称方法"""
        self.base_input(el_repair_config.repair_project_name, name)
        sleep()

    def input_repair_project_remark(self, remark):
        """输入备注方法"""
        self.base_input(el_repair_config.repair_project_remark, remark)
        sleep()

    def click_repair_project_submit(self):
        """点击提交按钮"""
        self.base_click(el_repair_config.repair_project_submit)
        sleep()

    def click_go_now(self):
        """点击现在去按钮"""
        self.base_click(el_repair_config.go_now)
        sleep()

    def click_repair_fee_add(self):
        """维修费用新增"""
        self.base_click(el_repair_config.repair_fee_add)
        sleep()

    def select_repair_fee_report_type(self):
        """选择维修费用上报类型"""
        self.base_click(el_repair_config.repair_fee_report_type)
        sleep()
        self.base_click(el_repair_config.repair_fee_report_type1)
        sleep()

    def select_repair_fee_repair_project(self):
        """选择维修费用维修项目"""
        self.base_click(el_repair_config.repair_fee_repair_project)
        sleep()
        self.base_click(el_repair_config.repair_fee_repair_project1)
        sleep()

    def select_charge_way(self):
        """选择收费方式"""
        self.base_click(el_repair_config.charge_way)
        sleep()

    def input_charge_amount(self, amount):
        """输入金额方法"""
        self.base_input(el_repair_config.charge_amount, amount)
        sleep()

    def input_repair_fee_remark(self, remark):
        """输入备注方法"""
        self.base_input(el_repair_config.repair_fee_remark, remark)
        sleep()

    def click_repair_fee_submit(self):
        """点击提交按钮"""
        self.base_click(el_repair_config.repair_fee_submit)
        sleep()

    def add_repair_project_fee(self, name, remark, amount):
        """新增维修项目维修费用"""
        with allure.step("点击新增按钮"):
            self.click_repair_project_add()
        with allure.step("选择维修项目上报类型"):
            self.select_repair_project_report_type()
        with allure.step(f"项目名称输入{name}"):
            self.input_repair_project_name(name)
        with allure.step(f"备注输入{remark}"):
            self.input_repair_project_remark(remark)
        with allure.step("点击确定按钮"):
            self.click_repair_project_submit()
        with allure.step("点击现在去按钮"):
            self.click_go_now()
        with allure.step("选择维修费用上报类型"):
            self.select_repair_fee_report_type()
        with allure.step("选择维修费用维修项目"):
            self.select_repair_fee_repair_project()
        with allure.step("选择收费方式"):
            self.select_charge_way()
        with allure.step(f"费用额度输入{amount}"):
            self.input_charge_amount(amount)
        with allure.step(f"备注输入{remark}"):
            self.input_repair_fee_remark(remark)
        with allure.step("点击确定按钮"):
            self.click_repair_fee_submit()

    def click_associated_room(self):
        """点击关联房间"""
        self.base_click(el_repair_config.associated_room)
        sleep()

    def click_select_all_room(self):
        """点击全选房间"""
        self.base_click(el_repair_config.select_all_room)
        sleep()

    def click_associated_room_submit(self):
        """点击确定按钮"""
        self.base_click(el_repair_config.associated_room_submit)
        sleep()

    def associated_room_config(self):
        """配置关联房间"""
        with allure.step("点击关联房间"):
            self.click_associated_room()
        with allure.step("点击全选按钮"):
            self.click_select_all_room()
        with allure.step("点击确定按钮"):
            self.click_associated_room_submit()

    def click_evaluate_config_add(self):
        """点击评价配置新建"""
        self.base_click(el_repair_config.evaluate_config_add)
        sleep()

    def input_evaluate_dimension(self, dimension):
        """输入评价维度"""
        self.base_input(el_repair_config.evaluate_dimension, dimension)
        sleep()

    def input_evaluate_content1(self, content1):
        """输入评价内容1"""
        self.base_input(el_repair_config.evaluate_content1, content1)
        sleep()

    def click_evaluate_content_add(self):
        """添加评价内容"""
        self.base_click(el_repair_config.evaluate_content_add)
        sleep()

    def input_evaluate_content2(self, content2):
        """输入评价内容2"""
        self.base_input(el_repair_config.evaluate_content2, content2)
        sleep()

    def select_evaluate_content_status(self):
        """选择启用状态"""
        self.base_click(el_repair_config.evaluate_content_status)
        sleep()

    def click_evaluate_config_submit(self):
        """点击提交按钮"""
        self.base_click(el_repair_config.evaluate_config_submit)
        sleep()

    def add_evaluate_config(self, dimension, content1, content2):
        """新增评价配置"""
        with allure.step("点击新建按钮"):
            self.click_evaluate_config_add()
        with allure.step(f"评价维度输入{dimension}"):
            self.input_evaluate_dimension(dimension)
        with allure.step(f"评价内容输入{content1}"):
            self.input_evaluate_content1(content1)
        with allure.step("添加评价内容"):
            self.click_evaluate_content_add()
        with allure.step(f"评价内容输入{content2}"):
            self.input_evaluate_content2(content2)
        with allure.step("选择启用状态"):
            self.select_evaluate_content_status()
        with allure.step("点击确定按钮"):
            self.click_evaluate_config_submit()

    def get_submit_msg(self):
        """获取提示信息"""
        sleep()
        return self.base_get_text(el_repair_config.msg)
